﻿var isEditClicked = 0;

$(document).ready(function () {
    $('#accountSettingsContainer').hide();
    $('.placeholderMenuItem_Clicked').removeClass('placeholderMenuItem_Clicked');
    $('#menuDashboard').attr('class', 'placeholderMenuItem_Clicked');

    $('.button').click(function () {
        $('#dialog-overlay, #dialog-box').hide();
        return false;
    });



    $(window).resize(function () {
        if (!$('#dialog-box').is(':hidden')) popup();
    });

});
//$(function () {
//    //$(window).focus();
//    $(window).keydown(function (event) {
//        var code = (event.keyCode ? event.keyCode : event.which);
//        if (event.shiftKey && code == 78) {
//            $('.placeholderMenuItem_Clicked').removeClass('placeholderMenuItem_Clicked');
//            window.location.href = "../pages/addCustomer.aspx";
//        }
//        else if (event.shiftKey && code == 68) {
//            window.location.href = "../pages/dashboard.aspx";
//        }
//    });
//});
function loadNewCustomerReg(obj) {
    //alert("appNewClicked");
    $('.placeholderMenuItem_Clicked').removeClass('placeholderMenuItem_Clicked');
    $(obj).attr('class', 'placeholderMenuItem_Clicked');
    window.location.href = "../../pages/customer.aspx";
}
function loadDashboard(obj) {
    window.location.href = "../../pages/dashboard.aspx";
}
function loadRenewAmc(obj) {
    $('.placeholderMenuItem_Clicked').removeClass('placeholderMenuItem_Clicked');
    $(obj).attr('class', 'placeholderMenuItem_Clicked');
    window.location.href = "../../pages/renewAMC.aspx";
}
function loadLogComplaint(obj) {
    $('.placeholderMenuItem_Clicked').removeClass('placeholderMenuItem_Clicked');
    $(obj).attr('class', 'placeholderMenuItem_Clicked');
    window.location.href = "../../pages/logComplaint.aspx";
}
function loadUserManagement(obj) {
    $('.placeholderMenuItem_Clicked').removeClass('placeholderMenuItem_Clicked');
    $(obj).attr('class', 'placeholderMenuItem_Clicked');
    window.location.href = "../../pages/addUsers.aspx";
}
function loadComplaintsSpl(obj) {
    $('.placeholderMenuItem_Clicked').removeClass('placeholderMenuItem_Clicked');
    $(obj).attr('class', 'placeholderMenuItem_Clicked');
    window.location.href = "../../pages/complaints/Default.aspx";
}
function loadAppSettings(obj) {
    $('.placeholderMenuItem_Clicked').removeClass('placeholderMenuItem_Clicked');
    $(obj).attr('class', 'placeholderMenuItem_Clicked');
    window.location.href = "../../pages/settings/default.aspx";
}
$("#menuDashboard").click(function () {
    alert("tab Dashboard clicked");
});

$(function () {
    $('#accountSettings').click(function () {
        $('#accountSettingsContainer').show();
        
        $('#accountSettingsContainer').dialog({
            width: 400,
            modal: true,
            title:"Account Settings"
        });
    });
});
//Popup dialog
function genericAlert(message) {
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();
    var dialogTop = (maskHeight / 3) - ($('#dialog-box').height());
    var dialogLeft = (maskWidth / 2) - ($('#dialog-box').width() / 2);
    $('#dialog-overlay').css({ height: maskHeight, width: maskWidth }).show();
    $('#dialog-box').css({ top: dialogTop, left: dialogLeft }).show();

    $('#dialog-message').html(message);

}
$(function () {
    $('#btnEditSettings').click(function () {
        isEditClicked = 1;
        $('#btnUpdate').show();
        $('#btnEditSettings').hide();
        $('#confirmPassword').show();
        $('#txtPassword').removeAttr('disabled');
        $('#txtconfirmPassword').removeAttr('disabled');
        $('#txtPhone').removeAttr('disabled');
    });
    $('#btnCancel').click(function () {
        if (isEditClicked == 1) {
            $('#btnUpdate').hide();
            $('#btnEditSettings').show();
            $('#confirmPassword').hide();
            $('#txtPassword').attr('disabled', 'disabled');
            $('#txtconfirmPassword').attr('disabled', 'disabled');
            $('#txtPhone').attr('disabled', 'disabled');
            isEditClicked = 0;
        }
        else {
            $('#accountSettingsContainer').dialog('close');
        }
    });
});